home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
tpgrwndw.zip
/
WINDOWS.DOC
< prev
next >
Wrap
Text File
|
1993-01-04
|
6KB
|
155 lines
Windows Version 1.00
By Todd Fiala
Introduction
This set of utilities is for use with Turbo Pascal 5.5. You must be
running Borland's Graphics System (use InitGraph). This public domain package
gives you a wide variety of subroutines for use in YOUR programs. These window
commands are for use in a graphics enviroment. The only thing not provided is
the actual implementation section for the unit.
Files contained :
Windows.doc : This documentary
Windows.pas : The Interface section for Windows.tpu
Windows.tpu : The Turbo Pascal 5.5 Unit file
Using Windows
To use windows.tpu in your programs, you must first set up the
Borland Graphics system, using a code segment something like this:
uses Windows, Graph;
var
grDriver,
grMode : word;
begin
grDriver := Detect;
InitGraph(grDriver,grMode,'');
.
.
.
end.
For best results, use mode
VGA VgaMed
MCGA McgaHi
EGA EgaHi
CGA CgaHi
To set the graphics mode, use
SetGraphMode(Mode);
Command Summary
This section will explain the use and purpose of each part ofwindows.tpu.
GLOBAL VARIABLES
ShowBor : (Boolean) When drawing any graphics window, if ShowBor is true,
a border will be drawn around the window. Disable border by typing
"ShowBor = false"
HitKey : (Boolean) This variable controls whether the window will be closed
after a key is hit or not. This works with OpenWndw and ShowWndw.
It is reset to false after all window calls. When true, the window
will automatically be closed after the next key is pressed.
TextCol : (word) This will be the color of the printed text on your graphics
windows. Initially set to 0 (Black text on white background)
BackCol : (word) This will be the main window color, the background color for
the text. Therefore you do not want to set BackCol = TextCol.
BorCol : (word) If ShowBor is True, then a border will be drawn around all
graphics windows of color BorCol.
PROCEDURES AND FUNCTIONS
In Windows.pas, a pretty good explanation for all of these functions and
procedures are given. This is just to clear up any misconceptions.
procedure ClearText
This will clear the internal window text buffer. Will not need to be
called unless you specifically want to wipe out what's in the buffer.
(cleared after windows are closed)
procedure WriteWndw(AddStr : string)
WriteWndw will add the text AddStr to the window text buffer. When a
graphics text window is open (with ShowWndw,CursorWndw, or OpenWndw), the text
in the window text buffer will be printed in the window.
procedure SetBuf
This will set the buffer reader to start reading from the beginning of the
buffer.
function ReadBuf(var ch : char) : boolean
Readbuf returns false if the buffer has been read to the end. Ch is the
next character it reads from the buffer.
function BufEmpty : boolean
This returns true if the buffer is indeed empty.
procedure GraphWndw(x1,y1,x2,y2 : word)
A window will be opened (close with CloseWndw). The area behind this
window will be saved. The window is defined by (x1,y1) upper left, (x2,y2)
lower right. A border will be drawn if ShowBor is True.
function GrPos(TextPos : word) : word
GrPos returns the text mode equivelant graphics starting position. For
example, since the standard character is 8 pixels wide, if you say GrPos(2), it
will return 8, because (2-1)*8 = 8. Remember, text mode positions start at
(1,1) while graphics mode coordinates start at (0,0), hence the (2-1)*8
instead of 2*8.
procedure FormatBuffer
You dont really need to worry about this. It is used to format the
Window Text Buffer for word wrap and is used by WriteText.
procedure WriteText(x1,y,x2 : word)
This procedure will write the text in the text buffer between (and
including) margins x1 and x2, starting at y. (All are Text Coordinates)
procedure OpenWndw(AddString : string; x1,y1,x2,y2 : word)
OpenWndw will open a window from text coordinates (x1,y1) {upper left}
to (x2,y2) {lower right}. It will add AddString to the Window Text Buffer and
then write all text to the window after opened. If HitKey is true, the window
will disappear as soon an a key is hit [useful for information windows]. If
HitKey is false, the window will remain open till closed with CloseWndw.
procedure ShowWndw(text : string)
This is the procedure to use if you don't want to worry about anything and
just print a nice looking window. It does all the work for you. It opens a
window as large as needed, centers it on the screen, and uses a nice word wrap.
Uses Hitkey as above.
function CursorWndw(AddString : string) : string
Quite a handy function, it will add the text AddString to the window Text
Buffer and open a window with a prompt line where it prints what you type. It
will return the string you type, and if Escape is pressed, will return a null
string('').
procedure CloseWndw
This procedure will close the last open window. If no window is open,
then nothing will happen.
procedure ClearAllWndws
A mop up utility, it will close all the open windows and clear the text
buffer. Should use to initialize the system.
ADDITIONAL NOTES
If you run a microsoft compatable mouse in your programs, you should
disable any mouse interrupts while calling window procedures, or errors WILL
occur.